<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
	<%@ include file="/common/query.jsp"%>
<script>
		var id = getQueryStringByDecode("id");
        $(function(){
            $.getJSON("${base}/sale/marketing/marketingInfo?id="+id,function (res) {
				console.log(res);
				for(var key in res.data){
					var value =res.data[key];
					if(key =="headUrl"){
						$('#'+key).attr("src",value);
					}else if(key == "sex" || key =="status" || key =='campus' ||key=='consultantGetMan' ||key=='collectPeople') {
						$('#'+key).val(value);
					}else{
						$('input[name='+key+']').val(value);
					}
				}
				$('#feedback').click();
            });

			$.getJSON("${base}/system/user/manager",function (res) {
				var html="";
				for(var i=0;i<res.data.length;i++){
					var row =res.data[i];
					html+='<option value="'+row.name+'">'+row.name+'</option>';
				}
				$('#consultantGetMan').append(html);
				$('#collectPeople').append(html);
			});
			$.getJSON("${base}/common/getAllCampus",function (res) {
				var campusHtml="";
				for(var j=0;j<res.data.length;j++){
					var row =res.data[j];
					campusHtml+='<option value="'+row.name+'">'+row.name+'</option>';
				}
				$('#orgID').append(campusHtml);
			});
			$.getJSON("${base}/member/grade/manager",function (res) {
				var gradeHtml="";
				for(var j=0;j<res.data.length;j++){
					var row =res.data[j];
					gradeHtml+='<option value="'+row.id+'">'+row.name+'</option>';
				}
				$('#grade').append(gradeHtml);
			});
        });
		function save() {
			var param = {};
			$('#base').find('input').each(function(){
				param[$(this).attr('name')] = $(this).val();
			});
			$('#base').find('select').each(function(){
				param[$(this).attr('name')] = $(this).val();
			});
			param.headUrl = $('#headUrl').attr('src');
			param.op = 'save';
			param.id =id;
			$.ajax({
				type : 'post',
				url : '${base}/sale/marketing/manager',
				data:param,
				async:false,
				dataType : 'json',
				success :  function(res){
					alert(res.msg);
					window.location.reload();
				}
			});
		}
        function feedback() {
			$('#feedbackContent').html('<iframe    src="${base}/sale/marketing/materialDetail?memberId='+id+'"  width="100%" height="'+($(window).height()-130)+'px"  frameborder="0"></iframe>');
        }
</script>
<style type="text/css">
	.spanDetail input{
		margin-bottom: 10px;
	}
	.spanDetail textarea{
		margin-bottom: -14px;
	}
</style>
</head>
<body>
	  <h1>市场活动</h1>
	  <div id="base">
		  <div class="layui-form-item">
			  <div class="layui-inline">
				  <label class="layui-form-label">活动名称:</label>
				  <div class="layui-input-inline">
					  <input type="text" name="activityName" lay-verify="required" autocomplete="off" placeholder="" class="layui-input">
				  </div>
			  </div>
			  <div class="layui-inline">
				  <label class="layui-form-label">活动英文:</label>
				  <div class="layui-input-inline">
					  <input type="text" name="activityEnName" lay-verify="required" autocomplete="off" placeholder="" class="layui-input">
				  </div>
			  </div>
			  <div class="layui-inline">
				  <label class="layui-form-label">组织机构:</label>
				  <div class="layui-input-inline">
					  <select name="orgID" id="orgID" style="margin-top: 10px;">
					  </select>
				  </div>
			  </div>
			  <div class="layui-inline">
				  <label class="layui-form-label">状态:</label>
				  <div class="layui-input-inline">
					  <input type="text" name="status" id="status" lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
				  </div>
			  </div>
			  <div class="layui-inline">
				  <label class="layui-form-label">活动类型:</label>
				  <div class="layui-input-inline">
					  <select name="activityType" id="activityType" style="margin-top: 10px;">
						  <option value="0">未知</option>
						  <option value="1">男</option>
						  <option value="2">女</option>
					  </select>
				  </div>
			  </div>
			  <div class="layui-inline">
				  <label class="layui-form-label">销售渠道ID:</label>
				  <div class="layui-input-inline">
					  <select name="saleChannelID" id="saleChannelID" style="margin-top: 10px;">
						  <option value="0">未知</option>
						  <option value="1">男</option>
						  <option value="2">女</option>
					  </select>
				  </div>
			  </div>
			  <div class="layui-inline">
				  <label class="layui-form-label">活动地点:</label>
				  <div class="layui-input-inline">
					  <input type="text" name="activityPlace" lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
				  </div>
			  </div>
			  <div class="layui-inline">
				  <label class="layui-form-label">活动说明:</label>
				  <div class="layui-input-inline">
					  <input type="text" name="activityDesc" lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
				  </div>
			  </div>
			  <div class="layui-inline" style ="margin-right: 9px">
				  <label class="layui-form-label">申请员工:</label>
				  <div class="layui-input-inline">
					  <input type="text" name="activityUID" lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
				  </div>
			  </div>
			  <div class="layui-inline">
				  <label class="layui-form-label">申请日期:</label>
				  <div class="layui-input-inline">
					  <input type="text" name="activityDate" lay-verify="required" autocomplete="off" placeholder="" class="layui-input">
				  </div>
			  </div>
			  <div class="layui-inline">
				  <label class="layui-form-label">预算总金额:</label>
				  <div class="layui-input-inline">
					  <input type="text" name="budgetAmount" lay-verify="required" autocomplete="off" placeholder="" class="layui-input">
				  </div>
			  </div>
			  <div class="layui-inline">
				  <label class="layui-form-label">实际总金额:</label>
				  <div class="layui-input-inline">
					  <input type="text" name="realAmount" lay-verify="required" autocomplete="off" placeholder="" class="layui-input">
				  </div>
			  </div>
			  <div class="layui-inline" style ="margin-right: 9px">
				  <label class="layui-form-label" >预算物料总金额:</label>
				  <div class="layui-input-inline">
					  <input type="text" name="budgetMatAmount" lay-verify="required" autocomplete="off" placeholder="" class="layui-input">
				  </div>
			  </div>
			  <div class="layui-inline">
				  <label class="layui-form-label">实际物料总金额:</label>
				  <div class="layui-input-inline">
					  <input type="text" name="realMatAmount" lay-verify="required" autocomplete="off" placeholder="" class="layui-input">
				  </div>
			  </div>
			  <div class="layui-inline">
				  <label class="layui-form-label">预算费用总金额:</label>
				  <div class="layui-input-inline">
					  <input type="text" name="budgetCostAmount" lay-verify="required" autocomplete="off" placeholder="" class="layui-input">
				  </div>
			  </div>
			  <div class="layui-inline">
				  <label class="layui-form-label">实际费用总金额:</label>
				  <div class="layui-input-inline">
					  <input type="text" name="realCostAmount" lay-verify="required" autocomplete="off" placeholder="" class="layui-input">
				  </div>
			  </div>
			  <div class="layui-inline">
				  <label class="layui-form-label">创建人:</label>
				  <div class="layui-input-inline layui-form" lay-filter="selFilter">
					  <input type="text" name="createUid" lay-verify="required" autocomplete="off" placeholder="" class="layui-input" disabled="disabled">
				  </div>
			  </div>
			  <div class="layui-inline">
				  <label class="layui-form-label">创建时间:</label>
				  <div class="layui-input-inline layui-form" lay-filter="selFilter">
					  <input type="text" name="createDate" lay-verify="required" autocomplete="off" placeholder="" class="layui-input" disabled="disabled">
				  </div>
			  </div>
			  <div class="layui-inline">
				  <label class="layui-form-label">创建组织:</label>
				  <div class="layui-input-inline layui-form" lay-filter="selFilter">
					  <input type="text" name="createOrgID" lay-verify="required" autocomplete="off" placeholder="" class="layui-input" disabled="disabled">
				  </div>
			  </div>
			  <div class="layui-inline">
				  <label class="layui-form-label">修改人:</label>
				  <div class="layui-input-inline layui-form" lay-filter="selFilter">
					  <input type="text" name="updateUid" lay-verify="required" autocomplete="off" placeholder="" class="layui-input" disabled="disabled">
				  </div>
			  </div>
			  <div class="layui-inline">
				  <label class="layui-form-label">修改时间:</label>
				  <div class="layui-input-inline layui-form" lay-filter="selFilter">
					  <input type="text" name="updateDate" lay-verify="required" autocomplete="off" placeholder="" class="layui-input" disabled="disabled">
				  </div>
			  </div>
			  <div class="layui-inline">
				  <label class="layui-form-label">修改组织:</label>
				  <div class="layui-input-inline layui-form" lay-filter="selFilter">
					  <input type="text" name="updateOrgID" lay-verify="required" autocomplete="off" placeholder="" class="layui-input" disabled="disabled">
				  </div>
			  </div>
			  <div class="layui-inline">
				  <label class="layui-form-label">审核人:</label>
				  <div class="layui-input-inline layui-form" lay-filter="selFilter">
					  <input type="text" name="reviewUid" lay-verify="required" autocomplete="off" placeholder="" class="layui-input" disabled="disabled">
				  </div>
			  </div>
			  <div class="layui-inline">
				  <label class="layui-form-label">审核时间:</label>
				  <div class="layui-input-inline layui-form" lay-filter="selFilter">
					  <input type="text" name="reviewData" lay-verify="required" autocomplete="off" placeholder="" class="layui-input" disabled="disabled">
				  </div>
			  </div>
			  <div class="layui-inline">
				  <label class="layui-form-label">审核组织:</label>
				  <div class="layui-input-inline layui-form" lay-filter="selFilter">
					  <input type="text" name="reviewOrgID" lay-verify="required" autocomplete="off" placeholder="" class="layui-input" disabled="disabled">
				  </div>
			  </div>
		  </div>
		  <button class="layui-btn" style="margin-left:10px;margin-top: 10px;"  onclick="save()">保存</button>
	  </div>
	  <div id="outerdiv" style="position:fixed;top:0;left:0;background:rgba(0,0,0,0.7);z-index:2000;width:100%;height:100%;display:none;">
		  <div id="innerdiv" style="position:absolute;">
			  <img id="bigimg" style="border:5px solid #fff;" src="" />
		  </div>
	  </div>
	  <div class="layui-tab">
		  <ul class="layui-tab-title">
			  <li id="feedback" onclick="feedback()">物料申请表</li>
	<%--		  <li>销售合同</li>
			  <li>课时账户</li>--%>
		  </ul>
		  <div class="layui-tab-content">
			  <div class="layui-tab-item" id="feedbackContent">
			  </div>
			  <div class="layui-tab-item">
				  销售合同表格
			  </div>
			  <div class="layui-tab-item">
				  课时账户表格
			  </div>
		  </div>
	  </div>
<script>
    layui.use(['element','from', 'layedit', 'laydate'], function() {
        var $ = layui.jquery
            , element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块
    });
	function imgShow(outerdiv, innerdiv, bigimg, _this){
		var src = _this.attr("src");//获取当前点击的pimg元素中的src属性
		$(bigimg).attr("src", src);//设置#bigimg元素的src属性

		/*获取当前点击图片的真实大小，并显示弹出层及大图*/
		$("<img/>").attr("src", src).load(function(){
			var windowW = $(window).width();//获取当前窗口宽度
			var windowH = $(window).height();//获取当前窗口高度
			var realWidth = this.width;//获取图片真实宽度
			var realHeight = this.height;//获取图片真实高度
			var imgWidth, imgHeight;
			var scale = 0.8;//缩放尺寸，当图片真实宽度和高度大于窗口宽度和高度时进行缩放

			if(realHeight>windowH*scale) {//判断图片高度
				imgHeight = windowH*scale;//如大于窗口高度，图片高度进行缩放
				imgWidth = imgHeight/realHeight*realWidth;//等比例缩放宽度
				if(imgWidth>windowW*scale) {//如宽度扔大于窗口宽度
					imgWidth = windowW*scale;//再对宽度进行缩放
				}
			} else if(realWidth>windowW*scale) {//如图片高度合适，判断图片宽度
				imgWidth = windowW*scale;//如大于窗口宽度，图片宽度进行缩放
				imgHeight = imgWidth/realWidth*realHeight;//等比例缩放高度
			} else {//如果图片真实高度和宽度都符合要求，高宽不变
				imgWidth = realWidth;
				imgHeight = realHeight;
			}
			$(bigimg).css("width",imgWidth);//以最终的宽度对图片缩放

			var w = (windowW-imgWidth)/2;//计算图片与窗口左边距
			var h = (windowH-imgHeight)/2;//计算图片与窗口上边距
			$(innerdiv).css({"top":h, "left":w});//设置#innerdiv的top和left属性
			$(outerdiv).fadeIn("fast");//淡入显示#outerdiv及.pimg
		});

		$(outerdiv).click(function(){//再次点击淡出消失弹出层
			$(this).fadeOut("fast");
		});
	}
</script>
</body>
</html>